package com.education.welco.mapper;

import com.education.welco.pojo.PlatformResources;
import com.education.welco.pojo.SResources;
import com.education.welco.pojo.vo.PathNodeVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Set;

/**
 * 平台资源 数据层
 *
 * @Author: liftsail
 * @Date: 2022-09-14
 * @Description: 不积跬步无以至千里
 */
@Mapper
public interface PlatformResourcesMapper {

    /**
     * 查询平台资源信息
     *
     * @param id 平台资源ID
     * @return 平台资源信息
     */
    public PlatformResources selectPlatformResourcesById(Integer id);

    /**
     * 查询平台资源列表
     *
     * @param platformResources 平台资源信息
     * @return 平台资源集合
     */
    public List<PlatformResources> selectPlatformResourcesList(PlatformResources platformResources);

    public List<PlatformResources> selectPlatformResourcesListForListDir(PlatformResources platformResources);

    public List<PlatformResources> selectPlatformResourcesListForSearch(PlatformResources platformResources);

    /**
     * 新增平台资源
     *
     * @param platformResources 平台资源信息
     * @return 结果
     */
    public int insertPlatformResources(PlatformResources platformResources);

    /**
     * 修改平台资源
     *
     * @param platformResources 平台资源信息
     * @return 结果
     */
    public int updatePlatformResources(PlatformResources platformResources);

    /**
     * 删除平台资源
     *
     * @param id 平台资源ID
     * @return 结果
     */
    public int deletePlatformResourcesById(String id);

    /**
     * 批量删除平台资源
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deletePlatformResourcesByIds(String[] ids);

    List<PlatformResources> selectPlatformResourcesListForListTheTypeFile(@Param("userId") Long userId, @Param("extensions") Set<String> extensions, @Param("bool") Integer bool);

    List<PlatformResources> findAllByUserIdAndDirAndDelete(@Param("userId") Long userId, @Param("isDir") Boolean dir, @Param("isDelete") Boolean delete);

    PlatformResources findByIdAndDelete(@Param("userFileId") String userFileId, @Param("bool") boolean bool);

    int updatePidByIdInAndPid(@Param("fromList") List<String> fromList, @Param("pid") String to);

    int updateRemarkByIds(@Param("fileIdList") List<String> fileIdList, @Param("fileRemark") String fileRemark);

    List<PlatformResources> findAllByIdInAndDelete(@Param("fileIdList") List<String> fileIdList, @Param("delete") Boolean delete);

    List<PlatformResources> findAllByPidInAndDelete(@Param("tmpIds") List<String> tmpIds, @Param("delete") Boolean delete);

    void updateDeleteByIdIn(@Param("fileIdList") List<String> fileIdList, @Param("delete") Boolean delete);

    List<PathNodeVO> findAllPathNodeByUserId(@Param("userId") Long userId);

    List<PlatformResources> selectPlatformResourcesListForListDirAndStarList(PlatformResources platformResources);

    int updatePlatformResourcesByIdListForShareState(@Param("childrenList") List<String> childrenList, @Param("shareState") boolean shareState);

    List<PlatformResources> selectShareSchoolResListBySchoolIdAndFileName(@Param("teaId") Integer teaId, @Param("ridALLCollect") List<String> ridALLCollect, @Param("fileName") String fileName, @Param("extensionSet") Set<String> extensionSet, @Param("inOrNot") Boolean inOrNot);

    List<PlatformResources> listTheDirByNameAndType(@Param("teaId") Long teaId,@Param("userId") Long userId, @Param("fileName") String fileName, @Param("extensionSet") Set<String> extensionSet, @Param("inOrNot") Boolean inOrNot, @Param("pid") String pid);

    /**
     * 通过id集合查询详细信息
     *
     * @param selectedIdList
     * @return
     */
    List<SResources> queryResInfoListByIdList(@Param("selectedIdList") List<String> selectedIdList);

    Integer deletePlatformResourcesByUrl(@Param("contentUrl") String contentUrl);

    Integer updatePlatformResourcesByUrl(@Param("contentUrl") String contentUrl, @Param("state") String state);
}